package com.xd.lib.listview.horizontal;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;

import com.xd.lib.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 测试横向滚动的ListView
 * Created by Administrator on 2015/6/5.
 */
public class HvListViewActivity extends Activity {

    private HvListView listView;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.hv_listview_layout);

        //数据展示列表
        listView = (HvListView)findViewById(R.id.hv_listview);
        listView.mListHead = (LinearLayout)findViewById(R.id.hv_listview_item_head);

        initData();
    }

    private void initData(){

        List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
        for (int i=0;i<50;i++){

            Map<String, Object> item = new HashMap<String, Object>();
            item.put("c1", i+"行1列");
            item.put("c2", i+"行2列");
            item.put("c3", i+"行3列");
            item.put("c4", i+"行4列");
            item.put("c5", i+"行5列");
            item.put("c6", i+"行6列");
            data.add(item);
        }
        HvListViewAdapter adapter = new HvListViewAdapter(this,
                data,
                R.layout.hv_listview_item,
                new String[]{
                        "c1",
                        "c2",
                        "c3",
                        "c4",
                        "c5",
                        "c6"
                },
                new int[]{
                        R.id.hv_listview_item_column1,
                        R.id.hv_listview_item_column2,
                        R.id.hv_listview_item_column3,
                        R.id.hv_listview_item_column4,
                        R.id.hv_listview_item_column5,
                        R.id.hv_listview_item_column6
                },
                listView
        );

        listView.setAdapter(adapter);
    }
}

